/*
 * PaymentCallback.java
 *
 * Created on April 25, 2007, 6:01 PM
 *
 * To change this template, choose Tools | Template Manager
 * and open the template in the editor.
 */

package vendingMachine.gui;

import vendingMachine.finance.*;
/**
 *
 * @author Derek Niles
 */
public class PaymentCallback extends AuthorizeCallback {
    
    private boolean wait;
    private AuthorizeObject o;
    
    /** Creates a new instance of PaymentCallback */
    public PaymentCallback() {
        wait = true;
    }
    
    public void onAuthorize(AuthorizeObject obj) {
        synchronized(this) {
            o = obj;
            if(obj.authorize())
                System.out.println("We are authorized");
            else
                System.out.println("Authorization Failed");
            wait = false;
        }
    }
    
    public boolean keepWaiting() {
        synchronized(this) {
            return wait;
        }
    }
    
    public AuthorizeObject getAuthorizeObject() {
        synchronized(this) {
            return o;
        }
    }
}
